<?
/*Created by : G.M.Sundar 
[created : 01/17/2007, 03:52:48 PM]
 Description:

*/
include("../../includes/global_files/tables.inc");

include(DOCINCLUDES."global_files/global_html.inc");
include(DOCINCLUDES."global_files/global_form.inc");//
include(DOCINCLUDES."global_files/global_report.inc");
include(DOCINCLUDES."global_files/tables.inc");
include(DOCINCLUDES."global_files/global_pgsql.inc");
include(DOCINCLUDES."global_files/global_functions.inc");



$page=new cPage;
$page->header_path="../../";

$form=new cForm();
$db=new cDatabase($company_id);
$report=new cReport();
$sql=new pgSql();//


if($_GET)
{
$commercial_id=$_GET['commercial_id'];

}

if(!$commercial_id)
{

$db->query="Select max(commercial_id) as commercial_id from $coo_commercial_details_table;";
$db->runQuery();
$coo_array=$db->returnArrays();
$coo_no_val=$coo_array[0]['commercial_id'];

$commercial_id=$coo_no_val;
}

$page->doHeaderHtml();

$db->query="select buyer as \"Buyer Name \",account as \"Account Name\",pre_carriage as \"Pre Carriage\",place_of_receipt as \"Place of Reciept\",shipment_mode_name as \"Shipment Mode \",city_name as \"City\",discharge as \"Discharge \",destination as \" Destination\",marks_and_nos as \"Mark and Nos.\",no_of_pkgs as \"No of Packages \",description as \"Description \",quantity_type_id as \"Quantity Type \",value as \"Value \",name_of_signatory as \"Name of the Authorised Signatory \",total_val as \"Total Value\",total_qty as \"Total Qty\" from $certificate_of_origin_view where commercial_id=$commercial_id;";

$db->runQuery();
$commercial_array=$db->returnArrays();

	$db->query="SELECT item_no as \"Item No.\",item_desc as \"Item Description\",remarks as \"Item Remarks\",qty as \"Quantity\",val as \"Value\" from $coo_item_details_table where commercial_id=$commercial_id;";


$db->runQuery();
$items_array=$db->returnArrays();

echo "<div align=\"center\">";
echo "<a href=\"coopdf.php?commercial_id=$commercial_id\">Print Document</a>  || <a
href=\"certificate_of_origin.php\"> Certificate of Origin Page </a>  || <a href=\"../reports/report_page.php?report_id=4\"> Certification of Origin Report</a> || <a href=\"certificate_of_origin.php?commercial_id=$commercial_id&action=edit\"> Edit</a>";
echo "<div>";
	$report->customization["table_style"]="width:50%; border-style:solid;
border-width:thin; border-collapse:collapse; aligin:left;";
	$report->customization["tr_style"]="border-style:none;
border-width:thin; border-collapse:collapse";
	$report->highlight=true;
	$report->title="Certificate of Origin Commercial Details";
	$report->data=$commercial_array;
	echo "<div align=\"center\">";
	$report->setNA();
	$report->doHorizontalTable();
	echo "</div>";
	echo "<BR>";
	echo "<BR>";

	$report->customization["table_style"]="width:50%; border-style:solid;
border-width:thin; border-collapse:collapse;";
	$report->customization["tr_style"]="border-style:none;
border-width:thin; border-collapse:collapse";
	$report->highlight=true;
	$report->title="Certificate of Origin Details";
	$report->setNA();
	$report->data=$items_array;
	echo "<div align=\"center\">";
	$report->doHorizontalTable();
	echo "</div>";
?>